home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / qwatch / qwatch.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-05-08  |  14.4 KB  |  399 lines

  1. VERSION 2.00
  2. Begin Form QWatch 
  3.    BackColor       =   &H00FFFFFF&
  4.    Caption         =   "Queue Watch"
  5.    ClientHeight    =   3525
  6.    ClientLeft      =   1470
  7.    ClientTop       =   1785
  8.    ClientWidth     =   4770
  9.    ForeColor       =   &H00FF8080&
  10.    Height          =   4215
  11.    Icon            =   QWATCH.FRX:0000
  12.    Left            =   1410
  13.    LinkMode        =   1  'Source
  14.    LinkTopic       =   "Form1"
  15.    ScaleHeight     =   3525
  16.    ScaleWidth      =   4770
  17.    Top             =   1155
  18.    Width           =   4890
  19.    Begin Timer WakeUp 
  20.       Left            =   4320
  21.       Top             =   3000
  22.    End
  23.    Begin PictureBox AppIcon 
  24.       Height          =   495
  25.       Left            =   2985
  26.       Picture         =   QWATCH.FRX:0302
  27.       ScaleHeight     =   465
  28.       ScaleWidth      =   465
  29.       TabIndex        =   14
  30.       TabStop         =   0   'False
  31.       Top             =   3000
  32.       Visible         =   0   'False
  33.       Width           =   495
  34.    End
  35.    Begin PictureBox Watch 
  36.       Height          =   495
  37.       Left            =   3600
  38.       Picture         =   QWATCH.FRX:0604
  39.       ScaleHeight     =   465
  40.       ScaleWidth      =   465
  41.       TabIndex        =   4
  42.       Top             =   2280
  43.       Width           =   495
  44.    End
  45.    Begin PictureBox Queue 
  46.       Height          =   495
  47.       Left            =   3600
  48.       Picture         =   QWATCH.FRX:0906
  49.       ScaleHeight     =   465
  50.       ScaleWidth      =   465
  51.       TabIndex        =   3
  52.       Top             =   1200
  53.       Width           =   495
  54.    End
  55.    Begin Frame Frame1 
  56.       BackColor       =   &H00FFFFFF&
  57.       Caption         =   "Warning Levels"
  58.       FontBold        =   -1  'True
  59.       FontItalic      =   0   'False
  60.       FontName        =   "MS Sans Serif"
  61.       FontSize        =   9.75
  62.       FontStrikethru  =   0   'False
  63.       FontUnderline   =   0   'False
  64.       ForeColor       =   &H00FF0000&
  65.       Height          =   2655
  66.       Left            =   360
  67.       TabIndex        =   7
  68.       Top             =   720
  69.       Width           =   2535
  70.       Begin TextBox RedLevel 
  71.          FontBold        =   -1  'True
  72.          FontItalic      =   0   'False
  73.          FontName        =   "MS Sans Serif"
  74.          FontSize        =   9.75
  75.          FontStrikethru  =   0   'False
  76.          FontUnderline   =   0   'False
  77.          Height          =   375
  78.          Left            =   1080
  79.          TabIndex        =   2
  80.          Text            =   "30"
  81.          Top             =   1920
  82.          Width           =   495
  83.       End
  84.       Begin PictureBox Red 
  85.          Height          =   495
  86.          Left            =   360
  87.          Picture         =   QWATCH.FRX:0C08
  88.          ScaleHeight     =   465
  89.          ScaleWidth      =   465
  90.          TabIndex        =   10
  91.          TabStop         =   0   'False
  92.          Top             =   1920
  93.          Width           =   495
  94.       End
  95.       Begin TextBox YellowLevel 
  96.          FontBold        =   -1  'True
  97.          FontItalic      =   0   'False
  98.          FontName        =   "MS Sans Serif"
  99.          FontSize        =   9.75
  100.          FontStrikethru  =   0   'False
  101.          FontUnderline   =   0   'False
  102.          ForeColor       =   &H00C00000&
  103.          Height          =   375
  104.          Left            =   1080
  105.          TabIndex        =   1
  106.          Text            =   "15"
  107.          Top             =   1200
  108.          Width           =   495
  109.       End
  110.       Begin PictureBox Yellow 
  111.          Height          =   495
  112.          Left            =   360
  113.          Picture         =   QWATCH.FRX:0F0A
  114.          ScaleHeight     =   465
  115.          ScaleWidth      =   465
  116.          TabIndex        =   9
  117.          TabStop         =   0   'False
  118.          Top             =   1200
  119.          Width           =   495
  120.       End
  121.       Begin PictureBox Green 
  122.          Height          =   495
  123.          Left            =   360
  124.          Picture         =   QWATCH.FRX:120C
  125.          ScaleHeight     =   465
  126.          ScaleWidth      =   465
  127.          TabIndex        =   8
  128.          TabStop         =   0   'False
  129.          Top             =   480
  130.          Width           =   495
  131.       End
  132.       Begin Label Label5 
  133.          Caption         =   "Jobs"
  134.          FontBold        =   -1  'True
  135.          FontItalic      =   0   'False
  136.          FontName        =   "MS Sans Serif"
  137.          FontSize        =   9.75
  138.          FontStrikethru  =   0   'False
  139.          FontUnderline   =   0   'False
  140.          Height          =   255
  141.          Left            =   1680
  142.          TabIndex        =   13
  143.          Top             =   1920
  144.          Width           =   495
  145.       End
  146.       Begin Label Label4 
  147.          Caption         =   "Jobs"
  148.          FontBold        =   -1  'True
  149.          FontItalic      =   0   'False
  150.          FontName        =   "MS Sans Serif"
  151.          FontSize        =   9.75
  152.          FontStrikethru  =   0   'False
  153.          FontUnderline   =   0   'False
  154.          Height          =   255
  155.          Left            =   1680
  156.          TabIndex        =   12
  157.          Top             =   1200
  158.          Width           =   495
  159.       End
  160.       Begin Label Label2 
  161.          BackColor       =   &H00FFFFFF&
  162.          Caption         =   "0        Jobs"
  163.          FontBold        =   -1  'True
  164.          FontItalic      =   0   'False
  165.          FontName        =   "MS Sans Serif"
  166.          FontSize        =   9.75
  167.          FontStrikethru  =   0   'False
  168.          FontUnderline   =   0   'False
  169.          ForeColor       =   &H00FF0000&
  170.          Height          =   255
  171.          Left            =   1080
  172.          TabIndex        =   11
  173.          Top             =   480
  174.          Width           =   1335
  175.       End
  176.    End
  177.    Begin ComboBox Server 
  178.       Height          =   300
  179.       Left            =   1200
  180.       Style           =   2  'Dropdown List
  181.       TabIndex        =   0
  182.       Top             =   240
  183.       Width           =   3255
  184.    End
  185.    Begin Label Label1 
  186.       BackColor       =   &H00FF0000&
  187.       Caption         =   "Watch"
  188.       ForeColor       =   &H00FFFFFF&
  189.       Height          =   210
  190.       Left            =   3570
  191.       TabIndex        =   5
  192.       Top             =   2775
  193.       Width           =   570
  194.    End
  195.    Begin Label Label6 
  196.       BackColor       =   &H00FF0000&
  197.       Caption         =   "Queues"
  198.       ForeColor       =   &H00FFFFFF&
  199.       Height          =   210
  200.       Left            =   3510
  201.       TabIndex        =   15
  202.       Top             =   1695
  203.       Width           =   705
  204.    End
  205.    Begin Label Label3 
  206.       BackColor       =   &H00FF0000&
  207.       Caption         =   "&Server"
  208.       FontBold        =   -1  'True
  209.       FontItalic      =   0   'False
  210.       FontName        =   "MS Sans Serif"
  211.       FontSize        =   9.75
  212.       FontStrikethru  =   0   'False
  213.       FontUnderline   =   0   'False
  214.       ForeColor       =   &H00FFFFFF&
  215.       Height          =   255
  216.       Left            =   360
  217.       TabIndex        =   6
  218.       Top             =   240
  219.       Width           =   735
  220.    End
  221.    Begin Menu mFile 
  222.       Caption         =   "&File"
  223.       Index           =   1
  224.       Begin Menu mExit 
  225.          Caption         =   "E&xit"
  226.          Index           =   2
  227.       End
  228.       Begin Menu mSeperator2 
  229.          Caption         =   "-"
  230.       End
  231.       Begin Menu mAbout 
  232.          Caption         =   "&About..."
  233.       End
  234.    End
  235. Sub Form_Load ()
  236.     Dim szServers As String * 160
  237.     Dim nEntries As Integer, nTotal As Integer
  238.     Dim nResult As Integer, nIndex As Integer, nParse As Integer
  239.     '*--------------------------------*
  240.     'query network for list of servers
  241.     '*--------------------------------*
  242.     nResult = NetServerEnum2("", 0, szServers, 160, nEntries, nTotal, &HFFFFFFFF, "")
  243.     '*---------------------------------*
  244.     'parse results returned in szServers
  245.     '*---------------------------------*
  246.     nIndex = 0: nParse = 1
  247.     While nIndex < nEntries
  248.         nStart = nParse
  249.         '*-------------------------------*
  250.         'search for ASCIIZ null terminator
  251.         '*-------------------------------*
  252.         While Asc(Mid$(szServers, nParse, 1)) <> 0
  253.             nParse = nParse + 1
  254.         Wend
  255.         '*--------------------------------------------------------------*
  256.         'use the AddItem Method to add server name to the server list box
  257.         '*--------------------------------------------------------------*
  258.         Server.AddItem Mid$(szServers, nStart, (nParse - nStart)), nIndex
  259.         nParse = nParse + 1
  260.         nIndex = nIndex + 1
  261.     Wend
  262. End Sub
  263. Sub Form_Paint ()
  264.     '*----------------------------------------------*
  265.     'determine if being restored from a 'Watch' state
  266.     '*----------------------------------------------*
  267.     If WakeUp.Interval = 5000 Then
  268.         '*---------------*
  269.         'de-activate timer
  270.         '*---------------*
  271.         WakeUp.Interval = 0
  272.         '*-----------------------------------------------------*
  273.         'reset window title from server name to application name
  274.         '*-----------------------------------------------------*
  275.         QWatch.Caption = "Queue Watch"
  276.         '*-------------------------------------------------------------*
  277.         'reset window icon from server warning state to application icon
  278.         '*-------------------------------------------------------------*
  279.         QWatch.Icon = AppIcon.Picture
  280.         '*----------------------------------------------------------*
  281.         'immediately invoke queues window if warning is yellow or red
  282.         '*----------------------------------------------------------*
  283.         If nWarning Then Queues.Show 1
  284.     End If
  285. End Sub
  286. Sub Label1_Click ()
  287.     '*---------------------------------------------------------------*
  288.     'allow clicking on the picture text(Watch) by invoking the picture
  289.     '*---------------------------------------------------------------*
  290.     Watch_Click
  291. End Sub
  292. Sub Label6_Click ()
  293.     '*----------------------------------------------------------------*
  294.     'allow clicking on the picture text(Queues) by invoking the picture
  295.     '*----------------------------------------------------------------*
  296.     Queue_Click
  297. End Sub
  298. Sub mExit_Click (Index As Integer)
  299.     '*------------------------------------------*
  300.     'close application by unloading the main form
  301.     '*------------------------------------------*
  302.     Unload QWatch
  303. End Sub
  304. Sub Queue_Click ()
  305.     '*-------------------------------------------------------*
  306.     'verify selection of a server and invoke the queues window
  307.     '*-------------------------------------------------------*
  308.     If Server.Text = "" Then
  309.         MsgBox "No Server Selected.", 16, "Show Queues"
  310.     Else
  311.         Queues.Show 1
  312.     End If
  313. End Sub
  314. Sub WakeUp_Timer ()
  315.     Static Share(49) As Share_Info
  316.     Dim Queue As PRQJINFO
  317.     Dim nEntries As Integer, nTotal As Integer, nNeeded As Integer
  318.     Dim nResult As Integer, nShare As Integer, nNewWarning
  319.     Dim szServer As String
  320.     '*-----------------------------------------------------------------*
  321.     'check whether application is in watch mode or just coming out of it
  322.     '*-----------------------------------------------------------------*
  323.     If WakeUp.Interval = 5000 Then
  324.         szServer = "\\" + QWatch.Caption + ""
  325.         '*---------------------------------------------------*
  326.         'query specified server for a list of shared resources
  327.         '*---------------------------------------------------*
  328.         nResult = NetShareEnum(szServer, 2, Share(0), 2000, nEntries, nTotal)
  329.         nNewWarning = 0
  330.         For nShare = 0 To nEntries
  331.             If Share(nShare).nType = 1 Then
  332.                 '*------------------------------------------------------*
  333.                 'if shared resource is a print queue then get information
  334.                 '*------------------------------------------------------*
  335.                 nResult = DosPrintQGetInfo(szServer, Share(nShare).lpPath, 1, Queue, 115, nNeeded)
  336.                 '*---------------------*
  337.                 'check if printer paused
  338.                 '*---------------------*
  339.                 If Queue.nStatus = 64 Then
  340.                     nNewWarning = 1
  341.                     '*----------------------*
  342.                     'check if printer offline
  343.                     '*----------------------*
  344.                 ElseIf Queue.nStatus = 32 Then
  345.                         nNewWarning = 2
  346.                     ElseIf Queue.nJobs Then
  347.                             '*-----------------------------------*
  348.                             'check if jobs exceed specified levels
  349.                             '*-----------------------------------*
  350.                             If Queue.nJobs >= Val(YellowLevel.Text) Then nNewWarning = 1
  351.                             If Queue.nJobs >= Val(RedLevel.Text) Then nNewWarning = 2
  352.                         End If
  353.             End If
  354.         Next
  355.         '*--------------------------------------------------*
  356.         'update application icon if warning state has changed
  357.         '*--------------------------------------------------*
  358.         If nNewWarning <> nWarning Then
  359.             Select Case nNewWarning
  360.                 Case 0
  361.                     QWatch.Icon = Green.Picture
  362.                 Case 1
  363.                     QWatch.Icon = Yellow.Picture
  364.                 Case 2
  365.                     QWatch.Icon = Red.Picture
  366.             End Select
  367.             nWarning = nNewWarning
  368.         End If
  369.     End If
  370. End Sub
  371. Sub Watch_Click ()
  372.     '*--------------------------*
  373.     'verify selection of a server
  374.     '*--------------------------*
  375.     If Server.Text = "" Then
  376.         MsgBox "No Server Selected.", 16, "Begin Watch"
  377.         GoTo ExitWatchClick
  378.     End If
  379.     '*-----------------------------*
  380.     'set window title to server name
  381.     '*-----------------------------*
  382.     QWatch.Caption = Server.Text
  383.                 
  384.     '*-------------------------------------------------------*
  385.     'set initial warning state to green and establish the icon
  386.     '*-------------------------------------------------------*
  387.     nWarning = 0
  388.     QWatch.Icon = Green.Picture
  389.     '*------------------*
  390.     'minimize application
  391.     '*------------------*
  392.     QWatch.WindowState = 1
  393.     '*--------------------------------------*
  394.     'set the timer to wake up every 5 seconds
  395.     '*--------------------------------------*
  396.     WakeUp.Interval = 5000
  397. ExitWatchClick:
  398. End Sub
  399.